﻿<!DOCTYPE html>
<!--作业许可证管理=>作业许可证申请=>附件添加页 -->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
     <script src="../static/js/common.js"></script>
    <style>
        .upload-demo {
            width: 360px
        }

        .el-upload-list__item-name {
            height: 30px;
            color: #606266;
            display: block;
            margin-right: 40px;
            overflow: hidden;
            padding-left: 4px;
            text-overflow: ellipsis;
            transition: color .3s;
            white-space: nowrap;
        }
    </style>
</head>
<body>

    <div id="app">
        <el-upload class="upload-demo"
                   ref="upload"
                   action="/api/File/PostFile"
                   multiple="true"
                   :on-preview="handlePreview"
                   :on-remove="handleRemove"
                   :file-list="fileList"
                   :auto-upload="false">
            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
            <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
    </div>
    <script>
        var Main = new Vue({
            el: '#app',
            data: {
                fileList: [{
                    name: 'food.jpeg',
                    url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
                },
                {
                    name: 'food2.jpeg',
                    url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
                }]
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                submitUpload: function () {
                    this.$refs.upload.submit();
                },
                handleRemove: function (file, fileList) {
                    console.log(file, fileList);
                },
                handlePreview: function (file) {

                    console.log(file);
                    window.open(file.url)
                }
            }
        });

    </script>
</body>
</html>